VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "mshflxgd.ocx"
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Begin VB.Form FBanco 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Bancos"
   ClientHeight    =   4935
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7575
   Icon            =   "FBanco.frx":0000
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4935
   ScaleWidth      =   7575
   StartUpPosition =   1  'CenterOwner
   Begin MSHierarchicalFlexGridLib.MSHFlexGrid HFG 
      Height          =   2175
      Left            =   1800
      TabIndex        =   1
      Top             =   600
      Width           =   5655
      _ExtentX        =   9975
      _ExtentY        =   3836
      _Version        =   393216
      FixedCols       =   0
      GridColor       =   12632256
      AllowBigSelection=   0   'False
      SelectionMode   =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _NumberOfBands  =   1
      _Band(0).Cols   =   2
   End
   Begin VB.Frame FraDatos 
      Enabled         =   0   'False
      Height          =   2055
      Left            =   1800
      TabIndex        =   2
      Top             =   2760
      Width           =   5655
      Begin VB.TextBox txtNombre 
         Height          =   765
         Left            =   1920
         MaxLength       =   150
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   6
         Top             =   600
         Width           =   3615
      End
      Begin VB.TextBox txtSigla 
         Height          =   285
         Left            =   1920
         MaxLength       =   10
         TabIndex        =   4
         Top             =   240
         Width           =   1215
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         Caption         =   "Nombre:"
         Height          =   255
         Left            =   960
         TabIndex        =   5
         Top             =   600
         Width           =   855
      End
      Begin VB.Label Label3 
         Alignment       =   1  'Right Justify
         Caption         =   "Sigla:"
         Height          =   255
         Left            =   960
         TabIndex        =   3
         Top             =   240
         Width           =   855
      End
   End
   Begin VB.Frame FraBotones 
      Height          =   4335
      Left            =   120
      TabIndex        =   7
      Top             =   480
      Width           =   1575
      Begin MSForms.CommandButton CmdSalir 
         Height          =   375
         Left            =   120
         TabIndex        =   13
         Top             =   3840
         Width           =   1335
         Caption         =   " Salir"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FBanco.frx":058A
         Accelerator     =   83
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdGuardar 
         Height          =   375
         Left            =   120
         TabIndex        =   11
         Top             =   2160
         Visible         =   0   'False
         Width           =   1335
         Caption         =   " Guardar"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FBanco.frx":06E4
         Accelerator     =   71
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdCancelar 
         Height          =   375
         Left            =   120
         TabIndex        =   12
         Top             =   2640
         Visible         =   0   'False
         Width           =   1335
         Caption         =   " Cancelar"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FBanco.frx":083E
         Accelerator     =   67
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdEliminar 
         Height          =   375
         Left            =   120
         TabIndex        =   10
         Top             =   1200
         Width           =   1335
         Caption         =   " Eliminar"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FBanco.frx":0998
         Accelerator     =   69
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdModificar 
         Height          =   375
         Left            =   120
         TabIndex        =   9
         Top             =   720
         Width           =   1335
         Caption         =   " Modificar"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FBanco.frx":0AF2
         Accelerator     =   77
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdNuevo 
         Height          =   375
         Left            =   120
         TabIndex        =   8
         Top             =   240
         Width           =   1335
         Caption         =   " Nuevo"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FBanco.frx":108C
         Accelerator     =   78
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
   End
   Begin VB.Label labTitulo 
      AutoSize        =   -1  'True
      Caption         =   "BANCOS"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3075
      TabIndex        =   0
      Top             =   0
      Width           =   1425
   End
End
Attribute VB_Name = "FBanco"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private codigo As String
Private fila As Integer

Private Sub CmdNuevo_Click()
    limpiarDatos
    habilitaBotones False
    habilitaFraDatos True
    enfocaControlInicial
    codigo = ""
End Sub
Private Sub CmdModificar_Click()
    fila = HFG.Row
    habilitaBotones False
    habilitaFraDatos True
    enfocaControlInicial
    codigo = HFG.TextMatrix(fila, 0)
End Sub
Private Sub CmdEliminar_Click()
    Dim o As ClsBanco
    fila = HFG.Row
    If fila > 0 Then
        codigo = HFG.TextMatrix(fila, 0)
        If MsgBox(MConfirma_Borrar, vbOKCancel) = vbOK Then
            Set o = New ClsBanco
            o.Borrar codigo
            cargarDatos
        End If
        codigo = ""
        fila = 0
    End If
End Sub

Private Sub cmdGuardar_Click()
    Dim o As ClsBanco
    If codigo = "" Then
        'nuevo registro
        Set o = New ClsBanco
        o.Nuevo TxtNombre.Text, txtSigla.Text
    ElseIf codigo <> "" Then
        'modifica registro
        Set o = New ClsBanco
        o.Modificar codigo, TxtNombre.Text, txtSigla.Text
    End If
    'actualiza datos
    cargarDatos
    'deshabilita botones
    Call cmdCancelar_Click
End Sub
Private Sub cmdCancelar_Click()
    habilitaBotones True
    habilitaFraDatos False
    If fila > 0 Then
        HFG.Row = fila
        'HFG.RowSel = fila
    End If
    HFG.SetFocus
End Sub

Private Sub CmdSalir_Click()
    Unload Me
End Sub
Private Sub limpiarDatos()
    TxtNombre.Text = ""
    txtSigla.Text = ""
End Sub
Private Sub habilitaFraDatos(habilitado As Boolean)
    HFG.enabled = Not habilitado
    FraDatos.enabled = habilitado
End Sub
Private Sub habilitaBotones(habilitado As Boolean)
    CmdNuevo.Visible = habilitado
    CmdModificar.Visible = habilitado
    CmdEliminar.Visible = habilitado
    CmdSalir.Visible = habilitado
    cmdGuardar.Visible = Not habilitado
    cmdCancelar.Visible = Not habilitado
End Sub
Private Sub enfocaControlInicial()
    With txtSigla
        .SetFocus
        .SelStart = 0
        .SelLength = Strings.LenB(.Text)
    End With
End Sub

Private Sub Form_Load()
    alineaForm Me, 2, 2
    cargarDatos
End Sub

Private Sub HFG_EnterCell()
    If HFG.Row > 0 Then
        txtSigla.Text = HFG.TextMatrix(HFG.Row, 1)
        TxtNombre.Text = HFG.TextMatrix(HFG.Row, 2)
    End If
End Sub

Public Sub cargarDatos()
    Dim o As ClsBanco
    Set o = New ClsBanco
    o.llenaGrid HFG, Array(0 * 15, 100 * 15, 250 * 15), Array("", "Nombre", "Sigla")
    limpiarDatos
End Sub

'eventos de movimiento entre controles
Private Sub txtSigla_KeyPress(KeyAscii As Integer)
    KeyAscii = mayusculas(KeyAscii)
End Sub
Private Sub TxtNombre_KeyPress(KeyAscii As Integer)
    Enter KeyAscii
End Sub
Private Sub HFG_KeyPress(KeyAscii As Integer)
    Enter KeyAscii
End Sub
